package com.ruoyi.web.controller.combat.camera;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.combat.domain.camera.CombatCameraException;
import com.ruoyi.combat.service.camera.ICombatCameraExceptionService;
import com.ruoyi.common.enums.BusinessType;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 摄像头异常情况Controller
 * 
 * @author ruoyi
 * @date 2025-01-23
 */
@Api(tags = "课题六：摄像头位置分析-摄像头异常检测信息")
@RestController
@RequestMapping("/camera/exception")
public class CombatCameraExceptionController extends BaseController
{
    @Autowired
    private ICombatCameraExceptionService combatCameraExceptionService;

    /**
     * 查询摄像头异常情况列表
     */
    @ApiOperation(value = "查询摄像头异常情况列表")
    @PreAuthorize("@ss.hasPermi('system:exception:list')")
    @GetMapping("/list")
    public TableDataInfo list(CombatCameraException combatCameraException)
    {
        startPage();
        List<CombatCameraException> list = combatCameraExceptionService.selectCombatCameraExceptionList(combatCameraException);
        return getDataTable(list);
    }

    /**
     * 导出摄像头异常情况列表
     */
    @ApiOperation(value = "导出摄像头异常情况列表")
    @PreAuthorize("@ss.hasPermi('system:exception:export')")
    @Log(title = "摄像头异常情况", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, CombatCameraException combatCameraException)
    {
        List<CombatCameraException> list = combatCameraExceptionService.selectCombatCameraExceptionList(combatCameraException);
        ExcelUtil<CombatCameraException> util = new ExcelUtil<CombatCameraException>(CombatCameraException.class);
        util.exportExcel(response, list, "摄像头异常情况数据");
    }

    /**
     * 获取摄像头异常情况详细信息
     */
    @ApiOperation(value = "获取摄像头异常情况详细信息")
    @PreAuthorize("@ss.hasPermi('system:exception:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(combatCameraExceptionService.selectCombatCameraExceptionById(id));
    }

    /**
     * 新增摄像头异常情况
     */
    @ApiOperation(value = "新增摄像头异常情况")
    @PreAuthorize("@ss.hasPermi('system:exception:add')")
    @Log(title = "摄像头异常情况", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody CombatCameraException combatCameraException)
    {
        return toAjax(combatCameraExceptionService.insertCombatCameraException(combatCameraException));
    }

    /**
     * 修改摄像头异常情况

     */
    @ApiOperation(value = "修改摄像头异常情况")
    @PreAuthorize("@ss.hasPermi('system:exception:edit')")
    @Log(title = "摄像头异常情况", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody CombatCameraException combatCameraException)
    {
        return toAjax(combatCameraExceptionService.updateCombatCameraException(combatCameraException));
    }

    /**
     * 删除摄像头异常情况

     */
    @ApiOperation(value = "删除摄像头异常情况")
    @PreAuthorize("@ss.hasPermi('system:exception:remove')")
    @Log(title = "摄像头异常情况", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(combatCameraExceptionService.deleteCombatCameraExceptionByIds(ids));
    }
}
